<template>
  <div style="width:100%;">
    <img
      style="width: 100%; height: 230px"
      v-if="moduleList.length>0"
      :src="sysConstant.FILE_SRC_PATH +moduleList[0].mhModule.bannerList[0].filePath"/>
    <el-menu
      style="display: flex;align-items: center;justify-content: center;"
      :default-active="activeIndex"
      mode="horizontal"
      background-color="#BF1108"
      text-color="#fff"
      active-text-color="#fff">
      <el-menu-item index="0" @click="toSY()" ><span style="font-size: 18px">首页</span></el-menu-item>
      <el-menu-item @click="toList(item.id)" v-for="(item,index) in menuList" :key="index" :index="(index+1)+''" ><span style="font-size: 18px">{{ item.name }}</span></el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  data() {
    return {
      imgPath: '',
      activeIndex:'0',
      menuList:[],
      moduleList:[],
      sysConstant:this.sysConstant
    }
  },
  components: {},
  created() {
    this.getBGImg()
    this.getMenuList()
  },
  methods: {
    getBGImg() {
      this.$http({
        url: this.$http.adornUrl('/mh/index/module/list'),
        method: 'get',
        params: this.$http.adornParams({'type': 0})
      }).then(({data}) => {
        if (data.success) {
           this.moduleList = data.data
          // this.getBGImg1(moduleId)
        }
      })
    },


    getMenuList(){
      this.$http({
        url: this.$http.adornUrl('/mh/menu/list'),
        method: 'get',
        params: this.$http.adornParams({'status': this.sysConstant.DATA_NORMAL_STATUS,'parentId':0,'showStatus':0})
      }).then(({data}) => {
        if (data.success) {
          this.menuList = data.data
        }
      })
    },
    toSY(){
      this.$router.replace({name: 'home'})
    },

    toList(id){
      this.$router.replace({'name': 'list','query': { 'menuId': id }})
    }

  }
}
</script>
